home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_grep.idb / usr / freeware / catman / u_man / cat1 / grep.Z / grep
Encoding:
Text File  |  1998-05-21  |  16.9 KB  |  331 lines

  1.  
  2.  
  3.  
  4.      GGGGRRRREEEEPPPP((((1111))))          GGGGNNNNUUUU PPPPrrrroooojjjjeeeecccctttt ((((1111999999992222    SSSSeeeepppptttteeeemmmmbbbbeeeerrrr 11110000))))           GGGGRRRREEEEPPPP((((1111))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.       grep,    egrep, fgrep - print lines matching a pattern
  10.  
  11.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.       ggggrrrreeeepppp [-AB] num] [-CEFGVbchiLlnqsvwxyUu] [-e pattern |    -f
  13.       file]    [--extended-regexp] [--fixed-strings] [--basic-regexp]
  14.       [--regexp=PATTERN] [--file=FILE] [--ignore-case] [--word-
  15.       regexp] [--line-regexp] [--line-regexp] [--no-messages] [--
  16.       revert-match]    [--version] [--help] [--byte-offset] [--line-
  17.       number] [--with-filename] [--no-filename] [--quiet] [--
  18.       silent] [--files-without-match] [--files-with-matcces] [--
  19.       count] [--before-context=NUM]    [--after-context=NUM] [--
  20.       context] [--binary] [--unix-byte-offsets] _f_i_l_e_s...
  21.  
  22.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  23.       GGGGrrrreeeepppp searches    the named input    _f_i_l_e_s (or standard input if no
  24.       files    are named, or the file name ---- is given)    for lines
  25.       containing a match to    the given _p_a_t_t_e_r_n.  By default,    ggggrrrreeeepppp
  26.       prints the matching lines.
  27.  
  28.       There    are three major    variants of ggggrrrreeeepppp, controlled by    the
  29.       following options.
  30.       ----GGGG,,,, --------bbbbaaaassssiiiicccc----rrrreeeeggggeeeexxxxpppp
  31.            Interpret _p_a_t_t_e_r_n as a basic regular expression (see
  32.            below).    This is    the default.
  33.       ----EEEE,,,, --------eeeexxxxtttteeeennnnddddeeeedddd----rrrreeeeggggeeeexxxxpppp
  34.            Interpret _p_a_t_t_e_r_n as an extended    regular    expression
  35.            (see below).
  36.       ----FFFF,,,, --------ffffiiiixxxxeeeedddd----ssssttttrrrriiiinnnnggggssss
  37.            Interpret _p_a_t_t_e_r_n as a list of fixed strings, separated
  38.            by newlines, any    of which is to be matched.
  39.       In addition, two variant programs eeeeggggrrrreeeepppp and ffffggggrrrreeeepppp are
  40.       available.  EEEEggggrrrreeeepppp is similar (but not    identical) to ggggrrrreeeepppp ----EEEE,
  41.       and is compatible with the historical    Unix eeeeggggrrrreeeepppp.  FFFFggggrrrreeeepppp is
  42.       the same as ggggrrrreeeepppp ----FFFF.
  43.  
  44.       All variants of ggggrrrreeeepppp understand the following    options:
  45.       ----nnnnuuuummmm Matches will be printed with _n_u_m    lines of leading and
  46.            trailing    context.  However, ggggrrrreeeepppp    will never print any
  47.            given line more than once.
  48.       ----AAAA  nnnnuuuummmm ,,,, --------aaaafffftttteeeerrrr----ccccoooonnnntttteeeexxxxtttt====NNNNUUUUMMMM
  49.            Print _n_u_m lines of trailing context after matching
  50.            lines.
  51.       ----BBBB  nnnnuuuummmm ,,,, --------bbbbeeeeffffoooorrrreeee----ccccoooonnnntttteeeexxxxtttt====NNNNUUUUMMMM
  52.            Print _n_u_m lines of leading context before matching
  53.            lines.
  54.       ----CCCC,,,, --------ccccoooonnnntttteeeexxxxtttt
  55.            Equivalent to ----2222.
  56.       ----VVVV,,,, --------vvvveeeerrrrssssiiiioooonnnn
  57.            Print the version number    of ggggrrrreeeepppp    to standard error.
  58.            This version number should be included in all bug
  59.            reports (see below).
  60.  
  61.  
  62.  
  63.      Page 1                          (printed 4/8/98)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      GGGGRRRREEEEPPPP((((1111))))          GGGGNNNNUUUU PPPPrrrroooojjjjeeeecccctttt ((((1111999999992222    SSSSeeeepppptttteeeemmmmbbbbeeeerrrr 11110000))))           GGGGRRRREEEEPPPP((((1111))))
  71.  
  72.  
  73.  
  74.       ----bbbb,,,, --------bbbbyyyytttteeee----ooooffffffffsssseeeetttt
  75.            Print the byte offset within the    input file before each
  76.            line of output.
  77.       ----cccc,,,, --------ccccoooouuuunnnntttt
  78.            Suppress    normal output; instead print a count of
  79.            matching    lines for each input file.  With the ----vvvv,,,, --------
  80.            rrrreeeevvvveeeerrrrtttt----mmmmaaaattttcccchhhh option (see    below),    count non-matching
  81.            lines.
  82.       ----eeee _p_a_t_t_e_r_n,,,,--_r_e_g_e_x_p=_P_A_T_T_E_R_N
  83.            Use _p_a_t_t_e_r_n as the pattern; useful to protect patterns
  84.            beginning with ----.
  85.       ----ffff _f_i_l_e,,,,--_f_i_l_e=_F_I_L_E
  86.            Obtain the pattern from _f_i_l_e.
  87.       ----hhhh,,,, --------nnnnoooo----ffffiiiilllleeeennnnaaaammmmeeee
  88.            Suppress    the prefixing of filenames on output when
  89.            multiple    files are searched.
  90.       ----iiii,,,, --------iiiiggggnnnnoooorrrreeee----ccccaaaasssseeee
  91.            Ignore case distinctions    in both    the _p_a_t_t_e_r_n and    the
  92.            input files.
  93.       ----LLLL,,,, --------ffffiiiilllleeeessss----wwwwiiiitttthhhhoooouuuutttt----mmmmaaaattttcccchhhh
  94.            Suppress    normal output; instead print the name of each
  95.            input file from which no    output would normally have
  96.            been printed. The scanning will stop on the first
  97.            match.
  98.       ----llll,,,, --------ffffiiiilllleeeessss----wwwwiiiitttthhhh----mmmmaaaattttcccchhhheeeessss
  99.            Suppress    normal output; instead print the name of each
  100.            input file from which output would normally have    been
  101.            printed.    The scanning will stop on the first match.
  102.       ----nnnn,,,, --------lllliiiinnnneeee----nnnnuuuummmmbbbbeeeerrrr
  103.            Prefix each line    of output with the line    number within
  104.            its input file.
  105.       ----qqqq,,,, --------qqqquuuuiiiieeeetttt
  106.            Quiet; suppress normal output. The scanning will    stop
  107.            on the first match.
  108.       ----ssss,,,, --------ssssiiiilllleeeennnntttt
  109.            Suppress    error messages about nonexistent or unreadable
  110.            files.
  111.       ----vvvv,,,, --------rrrreeeevvvveeeerrrrtttt----mmmmaaaattttcccchhhh
  112.            Invert the sense    of matching, to    select non-matching
  113.            lines.
  114.       ----wwww,,,, --------wwwwoooorrrrdddd----rrrreeeeggggeeeexxxxpppp
  115.            Select only those lines containing matches that form
  116.            whole words.  The test is that the matching substring
  117.            must either be at the beginning of the line, or
  118.            preceded    by a non-word constituent character.
  119.            Similarly, it must be either at the end of the line or
  120.            followed    by a non-word constituent character.  Word-
  121.            constituent characters are letters, digits, and the
  122.            underscore.
  123.       ----xxxx,,,, --------lllliiiinnnneeee----rrrreeeeggggeeeexxxxpppp
  124.            Select only those matches that exactly match the    whole
  125.            line.
  126.  
  127.  
  128.  
  129.      Page 2                          (printed 4/8/98)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      GGGGRRRREEEEPPPP((((1111))))          GGGGNNNNUUUU PPPPrrrroooojjjjeeeecccctttt ((((1111999999992222    SSSSeeeepppptttteeeemmmmbbbbeeeerrrr 11110000))))           GGGGRRRREEEEPPPP((((1111))))
  137.  
  138.  
  139.  
  140.       ----yyyy   Obsolete    synonym    for ----iiii.
  141.       ----UUUU,,,, --------bbbbiiiinnnnaaaarrrryyyy
  142.            Treat the file(s) as binary.  By    default, under MS-DOS
  143.            and MS-Windows, ggggrrrreeeepppp guesses the    file type by looking
  144.            at the contents of the first 32KB read from the file.
  145.            If ggggrrrreeeepppp decides the file    is a text file,    it strips the
  146.            CR characters from the original file contents (to make
  147.            regular expressions with    ^^^^ and $$$$    work correctly).
  148.            Specifying ----UUUU overrules this guesswork, causing all
  149.            files to    be read    and passed to the matching mechanism
  150.            verbatim; if the    file is    a text file with CR/LF pairs
  151.            at the end of each line,    this will cause    some regular
  152.            expressions to fail.  This option is only supported on
  153.            MS-DOS and MS-Windows.
  154.       ----uuuu,,,, --------uuuunnnniiiixxxx----bbbbyyyytttteeee----ooooffffffffsssseeeettttssss
  155.            Report Unix-style byte offsets.    This switch causes
  156.            ggggrrrreeeepppp to report byte offsets as if the file were Unix-
  157.            style text file,    i.e. with CR characters    stripped off.
  158.            This will produce results identical to running ggggrrrreeeepppp on
  159.            a Unix machine.    This option has    no effect unless ----bbbb
  160.            option is also used; it is only supported on MS-DOS and
  161.            MS-Windows.
  162.  
  163.      RRRREEEEGGGGUUUULLLLAAAARRRR EEEEXXXXPPPPRRRREEEESSSSSSSSIIIIOOOONNNNSSSS
  164.       A regular expression is a pattern that describes a set of
  165.       strings.  Regular expressions    are constructed    analogously to
  166.       arithmetic expressions, by using various operators to
  167.       combine smaller expressions.
  168.  
  169.       GGGGrrrreeeepppp understands two different versions of regular
  170.       expression syntax:  ``basic''    and ``extended.''  In
  171.       GNU ggggrrrreeeepppp, there is no    difference in available    functionality
  172.       using    either syntax.    In other implementations, basic
  173.       regular expressions are less powerful.  The following
  174.       description applies to extended regular expressions;
  175.       differences for basic    regular    expressions are    summarized
  176.       afterwards.
  177.  
  178.       The fundamental building blocks are the regular expressions
  179.       that match a single character.  Most characters, including
  180.       all letters and digits, are regular expressions that match
  181.       themselves.  Any metacharacter with special meaning may be
  182.       quoted by preceding it with a    backslash.
  183.  
  184.       A list of characters enclosed    by [[[[ and ]]]] matches any single
  185.       character in that list; if the first character of the    list
  186.       is the caret ^^^^ then it matches any character _n_o_t in the
  187.       list.     For example, the regular expression [[[[0000111122223333444455556666777788889999]]]]
  188.       matches any single digit.  A range of    ASCII characters may
  189.       be specified by giving the first and last characters,
  190.       separated by a hyphen.  Finally, certain named classes of
  191.       characters are predefined.  Their names are self
  192.  
  193.  
  194.  
  195.      Page 3                          (printed 4/8/98)
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      GGGGRRRREEEEPPPP((((1111))))          GGGGNNNNUUUU PPPPrrrroooojjjjeeeecccctttt ((((1111999999992222    SSSSeeeepppptttteeeemmmmbbbbeeeerrrr 11110000))))           GGGGRRRREEEEPPPP((((1111))))
  203.  
  204.  
  205.  
  206.       explanatory, and they    are [[[[::::aaaallllnnnnuuuummmm::::]]]], [[[[::::aaaallllpppphhhhaaaa::::]]]], [[[[::::ccccnnnnttttrrrrllll::::]]]],
  207.       [[[[::::ddddiiiiggggiiiitttt::::]]]], [[[[::::ggggrrrraaaapppphhhh::::]]]],    [[[[::::lllloooowwwweeeerrrr::::]]]], [[[[::::pppprrrriiiinnnntttt::::]]]], [[[[::::ppppuuuunnnncccctttt::::]]]],
  208.       [[[[::::ssssppppaaaacccceeee::::]]]], [[[[::::uuuuppppppppeeeerrrr::::]]]],    and [[[[::::xxxxddddiiiiggggiiiitttt::::]]]]....     For example,
  209.       [[[[[[[[::::aaaallllnnnnuuuummmm::::]]]]]]]] means [[[[0000----9999AAAA----ZZZZaaaa----zzzz]]]], except    the latter form    is
  210.       dependent upon the ASCII character encoding, whereas the
  211.       former is portable.  (Note that the brackets in these    class
  212.       names    are part of the    symbolic names,    and must be included
  213.       in addition to the brackets delimiting the bracket list.)
  214.       Most metacharacters lose their special meaning inside    lists.
  215.       To include a literal ]]]] place it first    in the list.
  216.       Similarly, to    include    a literal ^^^^ place it anywhere but
  217.       first.  Finally, to include a    literal    ---- place    it last.
  218.  
  219.       The period .... matches any single character.  The symbol \\\\wwww is
  220.       a synonym for    [[[[[[[[::::aaaallllnnnnuuuummmm::::]]]]]]]] and    \\\\WWWW is a    synonym    for
  221.       [[[[^^^^[[[[::::aaaallllnnnnuuuummmm]]]]]]]].
  222.  
  223.       The caret ^^^^ and the dollar sign $$$$ are    metacharacters that
  224.       respectively match the empty string at the beginning and end
  225.       of a line.  The symbols \\\\<<<< and \\\\>>>> respectively match the
  226.       empty    string at the beginning    and end    of a word.  The    symbol
  227.       \\\\bbbb matches the empty string at the edge of a word, and \\\\BBBB
  228.       matches the empty string provided it's _n_o_t at    the edge of a
  229.       word.
  230.  
  231.       A regular expression matching    a single character may be
  232.       followed by one of several repetition    operators:
  233.       ????    The preceding item is optional and matched at most
  234.            once.
  235.       ****    The preceding item will be matched zero or more times.
  236.       ++++    The preceding item will be matched one or more times.
  237.       {{{{_n}}}}  The preceding item is matched exactly _n times.
  238.       {{{{_n,,,,}}}} The preceding item is matched _n or more times.
  239.       {{{{,,,,_m}}}} The preceding item is optional and is matched at    most _m
  240.            times.
  241.       {{{{_n,,,,_m}}}}
  242.            The preceding item is matched at    least _n    times, but not
  243.            more than _m times.
  244.  
  245.       Two regular expressions may be concatenated; the resulting
  246.       regular expression matches any string    formed by
  247.       concatenating    two substrings that respectively match the
  248.       concatenated subexpressions.
  249.  
  250.       Two regular expressions may be joined    by the infix operator
  251.       ||||; the resulting regular expression matches any string
  252.       matching either subexpression.
  253.  
  254.       Repetition takes precedence over concatenation, which    in
  255.       turn takes precedence    over alternation.  A whole
  256.       subexpression    may be enclosed    in parentheses to override
  257.       these    precedence rules.
  258.  
  259.  
  260.  
  261.      Page 4                          (printed 4/8/98)
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.      GGGGRRRREEEEPPPP((((1111))))          GGGGNNNNUUUU PPPPrrrroooojjjjeeeecccctttt ((((1111999999992222    SSSSeeeepppptttteeeemmmmbbbbeeeerrrr 11110000))))           GGGGRRRREEEEPPPP((((1111))))
  269.  
  270.  
  271.  
  272.       The backreference \\\\_n,    where _n    is a single digit, matches the
  273.       substring previously matched by the _nth parenthesized
  274.       subexpression    of the regular expression.
  275.  
  276.       In basic regular expressions the metacharacters ????, ++++,    {{{{, ||||,
  277.       ((((, and )))) lose    their special meaning; instead use the
  278.       backslashed versions \\\\????, \\\\++++, \\\\{{{{, \\\\||||, \\\\((((, and \\\\)))).
  279.  
  280.       In eeeeggggrrrreeeepppp the metacharacter {{{{ loses its special meaning;
  281.       instead use \\\\{{{{.
  282.  
  283.      DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  284.       Normally, exit status    is 0 if    matches    were found, and    1 if
  285.       no matches were found.  (The ----vvvv option inverts the sense of
  286.       the exit status.)  Exit status is 2 if there were syntax
  287.       errors in the    pattern, inaccessible input files, or other
  288.       system errors.
  289.  
  290.      BBBBUUUUGGGGSSSS
  291.       Email    bug reports to bbbbuuuugggg----ggggnnnnuuuu----uuuuttttiiiillllssss@@@@pppprrrreeeepppp....aaaaiiii....mmmmiiiitttt....eeeedddduuuu.  Be sure
  292.       to include the word ``grep'' somewhere in the    ``Subject:''
  293.       field.
  294.  
  295.       Large    repetition counts in the {{{{_m,,,,_n}}}} construct may cause
  296.       grep to use lots of memory.  In addition, certain other
  297.       obscure regular expressions require exponential time and
  298.       space, and may cause ggggrrrreeeepppp to run out of memory.
  299.  
  300.       Backreferences are very slow,    and may    require    exponential
  301.       time.
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.      Page 5                          (printed 4/8/98)
  328.  
  329.  
  330.  
  331.